import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

declare module 'vue-router' {
    export interface RouteMeta {
        role?: 'admin' | 'teacher',
        aside?: boolean,
        header?: boolean,
        title?: string,
        loginNotRequired?: boolean,
    }
}

const routes: RouteRecordRaw[] = [
    {
        path: '/',
        redirect: '/home'
    }, {
        path: '/login',
        component: () => import('./views/Login.vue'),
        meta: {
            aside: false,
            header: false,
            title: '登录',
            loginNotRequired: true,
        }
    }, {
        path: '/test',
        component: () => import('./views/Test.vue'),
        meta: {
            aside: true,
            header: true,
            title: '测试页',
        }
    }, {
        path: '/home',
        component: () => import('./views/Home.vue'),
        meta: {
            aside: true,
            header: true,
            title: '主页',
        }
    }, {
        path: '/register',
        component: () => import('./views/Register.vue'),
        meta: {
            aside: false,
            header: false,
            title: '注册',
            loginNotRequired: true,
        }
    }, {
        path: '/template',
        component: () => import('./views/Template.vue'),
        meta: {
            aside: true,
            header: true,
            title: '审批流管理',
            loginNotRequired: true,
        }
    }, {
        path: '/user',
        component: () => import('./views/User.vue'),
        meta: {
            aside: true,
            header: true,
            title: '用户管理',
            loginNotRequired: true,
        }
    }, {
        path: '/approve',
        component: () => import('./views/Approve.vue'),
        meta: {
            aside: true,
            header: true,
            title: '审批管理',
            loginNotRequired: true,
        }
    }, {
        path: '/application',
        component: () => import('./views/Application.vue'),
        meta: {
            aside: true,
            header: true,
            title: '申请管理',
            loginNotRequired: true,
        }
    }, {
        path: '/template/:id',
        component: () => import('./views/TemplateInfo.vue'),
        meta: {
            aside: true,
            header: true,
            title: '审批流信息',
            loginNotRequired: true,
        }
    }, {
        path: '/template/:id/question',
        component: () => import('./views/TemplateQuestion.vue'),
        meta: {
            aside: true,
            header: true,
            title: '审批流问题编辑',
            loginNotRequired: true,
        }
    }, {
        path: '/template/:id/approver',
        component: () => import('./views/TemplateApprover.vue'),
        meta: {
            aside: true,
            header: true,
            title: '审批流审批人编辑',
            loginNotRequired: true,
        }
    }, {
        path: '/application/new',
        component: () => import('./views/ApplicationNew.vue'),
        meta: {
            aside: true,
            header: true,
            title: '发起新申请',
            loginNotRequired: true,
        }
    }, {
        path: '/application/info/:id',
        component: () => import('./views/ApplicationInfo.vue'),
        meta: {
            aside: true,
            header: true,
            title: '申请详情',
            loginNotRequired: true,
        }
    }, {
        path: '/application/new/fill/:id',
        component: () => import('./views/ApplicationFill.vue'),
        meta: {
            aside: true,
            header: true,
            title: '填写申请',
            loginNotRequired: true,
        }
    }, {
        path: '/application/view/:id',
        component: () => import('./views/ApplicationView.vue'),
        meta: {
            aside: true,
            header: true,
            title: '申请预览',
            loginNotRequired: true,
        }
    }
]

export const router = createRouter({
    history: createWebHistory(),
    routes: routes,
})